﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RBAC.Web.Service;
using RBAC.Web.Models;
namespace RBAC.Web.Mapper
{
    public class RoleMapper
    {
        public static RoleModel DtoToModel(RoleDto inputDto)
        {
            RoleModel result = new RoleModel();

            result.Id = inputDto.Id;
            result.RoleCode = inputDto.RoleCode;
            result.RoleName = inputDto.RoleName;
            result.Description = inputDto.Description;
            //result.CreateDate = inputDto.CreateDate;
            //result.RoleStatus = inputDto.RoleStatus;
            result.CreateDate = inputDto.CreateDate;
            result.CreateById = inputDto.CreateById;
            result.RoleStatus = inputDto.IsActive.GetValueOrDefault() ? 1 : 2;

            return result;
        }


        public static RoleDto ModelToDto(RoleModel inputModel)
        {


            RoleDto result = new RoleDto();

            result.Id = inputModel.Id;
            result.RoleCode = inputModel.RoleCode;
            result.RoleName = inputModel.RoleName;
            result.Description = inputModel.Description;

            result.CreateById = inputModel.CreateById;
            result.CreateDate = inputModel.CreateDate;
            result.IsActive = inputModel.RoleStatus == 1;

            return result;
        }

    }
}